﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using QuoteTree;
using System.IO;

public partial class Products : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.IsNewSession)
        {
            // If it says it is a new session, but an existing cookie exists, then it must 
            // have timed out (can't use the cookie collection because even on first 
            // request it already contains the cookie (request and response
            // seem to share the collection)
            string szCookieHeader = Request.Headers["Cookie"];
            if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
            {
                Response.Redirect("sessionTimeout.aspx");
            }
        }

        //Read product names from dir
        string[] dirs = Directory.GetDirectories(Server.MapPath("~/Private/Quotes"));
        string[] temp;
        for (int i = 0; i < dirs.Length; i++)
        {
            temp = dirs[i].Split("\\".ToCharArray());
            dirs[i] = temp[temp.Length - 1];
        }

        foreach (string t in dirs) 
        {
            ListItem item = new ListItem();
            item.Text = t;
            item.Value = "~/Private/TreeView.aspx?product=" + t ;
            this.BulletedList1.Items.Add(item);
        }
        this.Label1.Text = "Products:";
    }
}
